import java.io.IOException;
import java.util.ArrayList;

public class connectionObj {
	
	private long connectionID;
	private String connectionName;
	private String connectionString;
	ArrayList<connectionAction> actions = new ArrayList<connectionAction>();

	public long getConnectionID() {
		return connectionID;
	}
	public void setConnectionID(long connectionID) {
		this.connectionID = connectionID;
	}
	public String getConnectionName() {
		return connectionName;
	}
	public void setConnectionName(String connectionName) {
		this.connectionName = connectionName;
	}
	public String getConnectionString() {
		return connectionString;
	}
	public void setConnectionString(String connectionString) {
		this.connectionString = connectionString;
	}
	public void addAction(connectionAction action) {
		actions.add(action);
	}
	public void runActions(int type) {
		for (connectionAction ca : actions) { 
			if (ca.getActionType() == type) { 
				try {
					Runtime.getRuntime().exec(ca.getActionCommand());
				} catch (IOException e) {
					System.out.println("An error occured while trying to run the user defined command.");
					e.printStackTrace();
				}
			}
		}
	}
	
	public void runOkActions () {
		runActions(connectionAction.c_onClik);
	}
	public void runFailActions () { 
		runActions(connectionAction.c_onFail);
	}
	public void runClickActions() { 
		runActions(connectionAction.c_onClik);
	}
}

